﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using BLL;
namespace Stationery.UC
{
    public partial class UC_ChangePass : System.Web.UI.UserControl
    {
        BLL_User bll_User = new BLL_User();
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            string strPass = CurrentPassword.Text.Trim();
            if (Session[Utils.SESSION_LOGIN] != null)
            {
                User user = (User)Session[Utils.SESSION_LOGIN];
                if (user.PASSWORD == EncPass.EncryptString(strPass, Utils.SHARE_SECRETKEY))
                {
                    //thuc hien doi password
                    user.PASSWORD = EncPass.EncryptString(NewPassword.Text.Trim(), Utils.SHARE_SECRETKEY);
                    bll_User.InsertUpdate_User(user);
                    FailureText.Text = "Đổi mật khẩu thành công!";
                }
                else
                {
                    FailureText.Text = "Mật khẩu cũ không đúng!";
                }
            }
        }

        protected void CancelPushButton_Click(object sender, EventArgs e)
        {
            CurrentPassword.Text = "";
            NewPassword.Text = "";
            ConfirmNewPassword.Text = "";
        }

    }
}